from PIL import Image

def convert_to_ico(input_image_path, output_ico_path):
    """
    将指定路径的图片转换为.ico格式并保存到指定输出路径
    :param input_image_path: 输入图片的路径，例如 "example.jpg"
    :param output_ico_path: 输出.ico文件的路径，例如 "example.ico"
    """
    img = Image.open(input_image_path)
    img.save(output_ico_path, format='ICO', sizes=[(32, 32), (64, 64)])


if __name__ == "__main__":
    input_image_path = "globe.png"  # 在这里替换为你实际的输入图片路径
    output_ico_path = "globe.ico"  # 在这里替换为你想要保存的.ico文件路径
    convert_to_ico(input_image_path, output_ico_path)
